HTTP: Fix ded6170bd2072971f72db794f3ab1625a8e13475, which broke all HTTP calls.
authorAaron <aschulz@wikimedia.org>
Tue, 8 May 2012 22:18:10 +0000 (15:18 -0700)
committerTimo Tijhof <ttijhof@wikimedia.org>
Wed, 9 May 2012 06:35:14 +0000 (08:35 +0200)
* respHeaders contains arrays for each header (should've been
  respHeaders['content-length'][0] instead of respHeaders['content-length'])
  using getResponseHeader() instead.
* This also fixes InstantCommons, which was broken by this (bug 36653).
* Also cleaned up a bit of w/s in foreign repo code while in the area.

Change-Id: I429b0a36618cc2b873077516e9c1023dc5b7d693

includes/HttpFunctions.php
includes/filerepo/ForeignAPIRepo.php
includes/filerepo/file/ForeignAPIFile.php

index 054a836..d76b37f 100644 (file)
@@ -757,7 +757,7 @@ class CurlHttpRequest extends MWHttpRequest {
                $this->setStatus();
 
                if ( isset( $this->respHeaders['content-length'] ) ) {
-                       if ( strlen( $this->content ) < $this->respHeaders['content-length'] ) {
+                       if ( strlen( $this->content ) < $this->getResponseHeader( 'content-length' ) ) {
                                $this->status->fatal( 'http-truncated-body' );
                        }
                }
index 4f515a9..5fab3ab 100644 (file)
@@ -130,8 +130,8 @@ class ForeignAPIRepo extends FileRepo {
 
                $query = array_merge( $query,
                        array(
-                               'format' => 'json',
-                               'action' => 'query',
+                               'format'    => 'json',
+                               'action'    => 'query',
                                'redirects' => 'true'
                        ) );
                if ( $this->mApiBase ) {
index a5b8582..ef9c3a5 100644 (file)
@@ -54,9 +54,9 @@ class ForeignAPIFile extends File {
         */
        static function newFromTitle( Title $title, $repo ) {
                $data = $repo->fetchImageQuery( array(
-                       'titles' => 'File:' . $title->getDBKey(),
-                       'iiprop' => self::getProps(),
-                       'prop'   => 'imageinfo',
+                       'titles'            => 'File:' . $title->getDBKey(),
+                       'iiprop'            => self::getProps(),
+                       'prop'              => 'imageinfo',
                        'iimetadataversion' => MediaHandler::getMetadataVersion()
                ) );